package com.jh.netty.hj2122017.pojo;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * 检测数据
 *
 * 十分钟数据、小时数据、日数据（数据库 t_monitoring_data）
 */
public class MonitoringData {

    public Long id;

    public String dataTime;

    /**
     * 例如 a34004
     */
    public String type;

    /**
     * a34004-Min
     */
    public String min;

    /**
     * a34004-Avg
     */
    public String avg;

    /**
     * a34004-Max
     */
    public String max;

    /**
     * a34004-Flag
     */
    public String flag;


    public MonitoringData(String dataTime, String type, String min, String avg, String max, String flag) {
        this.dataTime = dataTime;
        this.type = type;
        this.min = min;
        this.avg = avg;
        this.max = max;
        this.flag = flag;
    }

    public MonitoringData() {
    }

    public static List<MonitoringData> from(Map<String, String> map) {

        String dt = map.get("DataTime");

        String a01001Min = map.get(MonitoringFactor.a01001 + "-Min");
        String a01001Avg = map.get(MonitoringFactor.a01001 + "-Avg");
        String a01001Max = map.get(MonitoringFactor.a01001 + "-Max");
        String a01001Flag = map.get(MonitoringFactor.a01001 + "-Flag");

        MonitoringData mdp = new MonitoringData(dt, MonitoringFactor.a01001.name(),
                a01001Min, a01001Avg, a01001Max, a01001Flag);


        String a01002Min = map.get(MonitoringFactor.a01002 + "-Min");
        String a01002Avg = map.get(MonitoringFactor.a01002 + "-Avg");
        String a01002Max = map.get(MonitoringFactor.a01002 + "-Max");
        String a01002Flag = map.get(MonitoringFactor.a01002 + "-Flag");

        MonitoringData mdp2 = new MonitoringData(dt, MonitoringFactor.a01002.name(),
                a01002Min, a01002Avg, a01002Max, a01002Flag);


        String a01006Min = map.get(MonitoringFactor.a01006 + "-Min");
        String a01006Avg = map.get(MonitoringFactor.a01006 + "-Avg");
        String a01006Max = map.get(MonitoringFactor.a01006 + "-Max");
        String a01006Flag = map.get(MonitoringFactor.a01006 + "-Flag");

        MonitoringData mdp3 = new MonitoringData(dt, MonitoringFactor.a01006.name(),
                a01006Min, a01006Avg, a01006Max, a01006Flag);


        String a01007Min = map.get(MonitoringFactor.a01007 + "-Min");
        String a01007Avg = map.get(MonitoringFactor.a01007 + "-Avg");
        String a01007Max = map.get(MonitoringFactor.a01007 + "-Max");
        String a01007Flag = map.get(MonitoringFactor.a01007 + "-Flag");

        MonitoringData mdp4 = new MonitoringData(dt, MonitoringFactor.a01007.name(),
                a01007Min, a01007Avg, a01007Max, a01007Flag);


        String a01008Min = map.get(MonitoringFactor.a01008 + "-Min");
        String a01008Avg = map.get(MonitoringFactor.a01008 + "-Avg");
        String a01008Max = map.get(MonitoringFactor.a01008 + "-Max");
        String a01008Flag = map.get(MonitoringFactor.a01008 + "-Flag");

        MonitoringData mdp5 = new MonitoringData(dt, MonitoringFactor.a01008.name(),
                a01008Min, a01008Avg, a01008Max, a01008Flag);


        String a34001Min = map.get(MonitoringFactor.a34001 + "-Min");
        String a34001Avg = map.get(MonitoringFactor.a34001 + "-Avg");
        String a34001Max = map.get(MonitoringFactor.a34001 + "-Max");
        String a34001Flag = map.get(MonitoringFactor.a34001 + "-Flag");

        MonitoringData mdp6 = new MonitoringData(dt, MonitoringFactor.a34001.name(),
                a34001Min, a34001Avg, a34001Max, a34001Flag);


        String a34002Min = map.get(MonitoringFactor.a34002 + "-Min");
        String a34002Avg = map.get(MonitoringFactor.a34002 + "-Avg");
        String a34002Max = map.get(MonitoringFactor.a34002 + "-Max");
        String a34002Flag = map.get(MonitoringFactor.a34002 + "-Flag");

        MonitoringData mdp7 = new MonitoringData(dt, MonitoringFactor.a34002.name(),
                a34002Min, a34002Avg, a34002Max, a34002Flag);


        String a34004Min = map.get(MonitoringFactor.a34004 + "-Min");
        String a34004Avg = map.get(MonitoringFactor.a34004 + "-Avg");
        String a34004Max = map.get(MonitoringFactor.a34004 + "-Max");
        String a34004Flag = map.get(MonitoringFactor.a34004 + "-Flag");

        MonitoringData mdp8 = new MonitoringData(dt, MonitoringFactor.a34004.name(),
                a34004Min, a34004Avg, a34004Max, a34004Flag);


        String a50001Min = map.get(MonitoringFactor.a50001 + "-Min");
        String a50001Avg = map.get(MonitoringFactor.a50001 + "-Avg");
        String a50001Max = map.get(MonitoringFactor.a50001 + "-Max");
        String a50001Flag = map.get(MonitoringFactor.a50001 + "-Flag");

        MonitoringData mdp9 = new MonitoringData(dt, MonitoringFactor.a50001.name(),
                a50001Min, a50001Avg, a50001Max, a50001Flag);


        List<MonitoringData> list = new ArrayList<>();
        list.add(mdp);
        list.add(mdp2);
        list.add(mdp3);
        list.add(mdp4);
        list.add(mdp5);
        list.add(mdp6);
        list.add(mdp7);
        list.add(mdp8);
        list.add(mdp9);
        return list;
    }
}
